import 'package:flutter/material.dart';
import 'dart:math' as math;

import 'my_drawer.dart';

void main() => runApp(const MyApp());

class MyApp extends StatefulWidget {
  const MyApp({Key? key}) : super(key: key);

  static const String _title = 'Flutter Code Sample';

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  int _selectedIndex = 1;

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        title: MyApp._title,
        home: Scaffold(
          appBar: AppBar(
            title: Text("APP Name"),
            actions: [
              IconButton(
                onPressed: () => print("点击分享"),
                icon: Icon(Icons.share),
                color: Colors.white,
              )
            ],
            leading: Builder(builder: (context) {
              return IconButton(
                onPressed: () {
                  Scaffold.of(context).openDrawer();
                },
                icon: Icon(Icons.dashboard_outlined),
                color: Colors.white,
              );
            }),
          ),
          body: Text(""),
          drawer: MyDrawer(),
          // bottomNavigationBar: BottomNavigationBar(
          //   items: [
          //     BottomNavigationBarItem(icons: Icon(Icons.home), label: "主页"),
          //     BottomNavigationBarItem(icons: Icon(Icons.business), label: "商场"),
          //     BottomNavigationBarItem(icons: Icon(Icons.school), label: "学校"),
          //   ],
          //   currentIndex: _selectedIndex,
          //   fixedColor: Colors.orange,
          //   onTap: _onItemTapped,
          // ),
          bottomNavigationBar: BottomAppBar(
            shape: CircularNotchedRectangle(),
            child: Row(
              mainAxisAlignment: MainAxisAlignment.spaceAround,
              children: [
                IconButton(icon: Icon(Icons.home), onPressed: _onItemTapped(1)),
                SizedBox(),
                IconButton(icon: Icon(Icons.business), onPressed: _onItemTapped(2)),
              ],
            ),
          ),
          floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
          floatingActionButton: FloatingActionButton(
            onPressed: () {
              print("点击悬浮按钮");
            },
            child: Icon(Icons.add),
          ),
        ));
  }

  _onItemTapped(int index) {
    setState(() {
      _selectedIndex = index;
    });
  }
}
